﻿using System;
using System.Web.Mvc;
using System.Web;

namespace JinianNet.JNCms.Filters
{
    public class ErrorMessagesFilter : BasePageFilter
    {
        #region IExceptionFilter 成员

        public override void OnException(ExceptionContext filterContext)
        {
            //throw new NotImplementedException();
            //Tips(filterContext.HttpContext.Response,filterContext.Exception.Message, null, false, filterContext.Exception.ToString());
            System.IO.FileInfo info = new System.IO.FileInfo(filterContext.HttpContext.Server.MapPath(string.Concat("~/Log/",DateTime.Now.ToString("yyyyMMdd"),".txt")));
            if (!info.Directory.Exists)
            {
                info.Directory.Create();
            }
            System.IO.File.AppendAllText(info.FullName, string.Concat("\r\n", DateTime.Now.ToString(), "\r\n", filterContext.Exception.ToString(), "\r\n-------------------------------------------------------------------------\r\n\r\n"));
            base.OnException(filterContext);
        }
        #endregion
    }
}
